<include file="common/header" />
<script type="text/javascript" src="/javascript/home/juicer-min.js"></script>
<script type='text/javascript'  src='/kindeditor/kindeditor.js'></script>

<div class="main-container">
    <div class="container" id="wrap-detail">
        <div class="row mb10">
            <div class="col-sm-8">
                <h1 class="detail-title mb15">{$deal_info.name}</h1>

                <div>
                    <span class="mr10">发起人：{$deal_info.user_name}</span>
                    <span>{$deal_info.province}{$deal_info.city}</span>
                </div>
            </div>
            <div class="col-sm-4 text-right">
                <if condition="($user.id neq $deal_info['user_id'])">
                    <if condition="($deal_info.end_time lt $now) AND ($deal_info.end_time neq 0)">
                        <button class="ui-btn ui-btn-blue btn-support mr10 ui-btn-disabled">
                            <i class="glyphicon glyphicon-star"></i><span>支持</span>
                        </button>
                        <else/>
                        <button class="ui-btn ui-btn-blue btn-support mr10" data-toggle="modal" data-target=".modal-support">
                            <i class="glyphicon glyphicon-star"></i><span>支持</span>
                        </button>
                    </if>
                <button class="ui-btn <if condition="($fav_status eq 1)">ui-btn-disabled<else />ui-btn-red</if> btn-like" id="add-like" data-id="{$deal_info.id}"><i class="glyphicon glyphicon-heart"></i><span class="like-text"><if condition="($fav_status eq 1)">不再喜欢<else />喜欢</if></span></button>
                </if>
            </div>
            <div class="modal modal-support" tabindex="-1" role="dialog"  aria-hidden="true">
                <div class="modal-dialog dialog-support">
                    <div class="modal-content">
                        <button class="ui-btn ui-btn-blue btn-add-close" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i></button>
                        <div class="modal-support-head">
                            选择你的支持项目
                        </div>
                        <div class="modal-support-content">
                            <volist name="deal_item_list" id="vo" key="k">
                                <div class="support-item <if condition="($support_full gt 1)">support-full</if>">
                                <div class="clearfix mb15">
                                    <span class="pull-left support-money">￥{$vo.price_format}</span>
                                    <if condition="($deal_info.end_time lt $now) AND ($deal_info.end_time neq 0)">
                                        <a class="ui-btn btn-support ui-btn-blue pull-right mt10 ui-btn-disabled">项目过期</a>
                                        <else/>
                                        <a <if condition="($vo.support_full eq 0)">href="/cart.html?id={$vo.id}"</if> class="ui-btn btn-support ui-btn-blue pull-right mt10 <if condition="($vo.support_full eq 1)">ui-btn-disabled</if>"><if condition="($vo.support_full eq 1)">限额已满<else />支持</if></a>
                                    </if>
                                </div>
                                <h1>{$vo.title}</h1>
                                <p class="mb20">{$vo.description|nl2br}</p>
                                <p><if condition="($vo.limit_user eq 0)">不限购买人数<else />限额<span class="fc-red">{$vo.limit_user}</span>位，剩余<span class="fc-red">{$vo.limit_remain}</span>位</if></p>
                                <p class="fc9 mt10 mb5">预计回报发放时间:项目成功结束后{$vo.repaid_day}天</p>
                                <p class="fc9"><if condition="($vo.is_delivery eq 1)"><if condition="($vo.delivery_fee gt 0)">¥{$vo.delivery_fee|round=2}<else />全国包邮</if><else />不需要配送</if></p>
                        </div>
                        </volist>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row hidden-lg">
        <div class="col-xs-12" style="position: relative;height: 22px;">
            <!-- JiaThis Button BEGIN -->
            <div style="position: absolute;right: 0;">
                <div class="jiathis_style">
                    <a class="jiathis_button_qzone"></a>
                    <a class="jiathis_button_tsina"></a>
                    <a class="jiathis_button_weixin"></a>
                    <a class="jiathis_button_renren"></a>
                    <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
                    <a class="jiathis_counter_style"></a>
                </div>
                <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
            </div>
            <!-- JiaThis Button END -->
        </div>
    </div>
    <div class="row">
        <div class="col-sm-8">
            <div class="detail-wrap">
                <div class="detail-sum clearfix p10 mb20">
                    <div class="sum-title pull-left mr10">
                        <p>项目简介</p>
                    </div>
                    <div class="sum-text">
                        {$deal_info.brief}
                    </div>
                </div>
                <div class="detail-content">
                    <div class="detail-index mb20">
                        <ul class="clearfix wrap-detail-tabs">
                            <li><a href="/deal/show/?id={$deal_info.id}">项目主页</a><i class="glyphicon glyphicon-arrow-down detail-tabs-icon"></i></li>
                            <li class="current"><a href="/deal/status/?id={$deal_info.id}">项目进展 </a><i class="glyphicon glyphicon-arrow-down detail-tabs-icon"></i></li>
                            <li><a href="/deal/comment/?id={$deal_info.id}">咨询评论</a><i class="glyphicon glyphicon-arrow-down detail-tabs-icon"></i></li>
                            <li><a href="/deal/intro/?id={$deal_info.id}">自我介绍 </a><i class="glyphicon glyphicon-arrow-down detail-tabs-icon"></i></li>
                        </ul>
                        <div class="wrap-share visible-lg">
                            <!-- JiaThis Button BEGIN -->
                            <div class="jiathis_style">
                                <a class="jiathis_button_qzone"></a>
                                <a class="jiathis_button_tsina"></a>
                                <a class="jiathis_button_weixin"></a>
                                <a class="jiathis_button_renren"></a>
                                <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
                                <a class="jiathis_counter_style"></a>
                            </div>
                            <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
                            <!-- JiaThis Button END -->
                        </div>
                        <if condition="($project_owner eq 1)">
                        <div class="detail-textarea">
                            <div class="box-textarea">
                                <textarea placeholder="请在此输入项目进展状态" id="dis-content" rows="10"></textarea>
                            </div>
                        </div>
                        <div class="row plr15 mb20">
                            <button class="ui-btn ui-btn-blue col-xs-3 btn-answer col-xs-offset-9" id="send-dis" deal-id="{$deal_info.id}">发表状态<i
                                    class="glyphicon glyphicon-chevron-right ml10 f16"></i></button>
                        </div>
                        </if>
                        <div class="trends-content">
                            <ul>
                                <volist name="list" id="vo" key="k">
                                <li class="trends-item" style="padding-bottom:0px;">
                                    <div class="line-time">
                                        <div class="square"></div>
                                        <span>{$key}月</span>
                                    </div>
                                    <div class="trends-main">
                                        <ul>
                                            <volist name="vo" id="xo" key="k">
                                            <li class="trends-text-item clearfix">
                                                <div class="trends-day pull-left">
                                                    {$xo.day}
                                                </div>
                                                <div class="trends-text">
                                                    {$xo.content}
                                                </div>
                                                <div class="appraise" data-id="{$xo.id}" data-toggle="collapse" data-target="#discuss-item{$xo.id}" aria-expanded="false" aria-controls="discuss-item{$xo.id}"  deal-id="{$deal_info.id}">
                                                    评论({$xo.comment_total})
                                                </div>
                                                <div class="collapse mt35" id="discuss-item{$xo.id}">
                                                    <div class="well">
                                                        <if condition="($has_order eq 0)">
                                                            <div class="alert alert-info text-center" role="alert">
                                                                只有该项目支持者才能发表评论
                                                            </div>
                                                            <else />
                                                            <div class="dis-textarea" style="min-height:350px;">
                                                                <!-- 这里ajaxPOST提交评论 -->
                                                                <!--<textarea name="content" class="setting-sum content{$xo.id}" placeholder="您的回复可更有效的帮助支持者了解您和了解项目的背景"></textarea>-->
                                                                <script type='text/javascript'>
                                                                var VAR_MODULE = "m";
                                                                var VAR_ACTION = "a";
                                                                var ROOT = '/index.php';
                                                                var ROOT_PATH = '/';
                                                                var eid = 'pro_status-textarea';
                                                                var editor;
                                                                KindEditor.ready(function(K) {
                                                                window.editor = K.create('textarea[name="content"]', {
                                                                resizeType : 2,
                                                                uploadJson : '/File/do_upload_img', // 相对于当前页面的路径
                                                                items : ['source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
                                                                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                                                                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                                                                'superscript', '|', 'selectall', '-',
                                                                'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
                                                                'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
                                                                'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about']
                                                                });
                                                                });
                                                                </script>
                                                                <textarea class="setting-sum content{$xo.id}" name="content" id="pro_status-textarea" placeholder="您的回复可更有效的帮助支持者了解您和了解项目的背景" style='width:100%; min-height:350px;'></textarea>

                                                                <button class="ui-btn ui-btn-blue btn-discuss send-discuss" data-id="{$xo.id}" deal-id="{$deal_info.id}">评论</button>
                                                            </div>
                                                        </if>

                                                        <ul class="dis-list dis-list{$xo.id}">
                                                            <!-- 这里ajax读取 -->
                                                        </ul>
                                                    </div>
                                                </div>
                                            </li>
                                            </volist>
                                        </ul>
                                    </div>
                                </li>
                                </volist>
                                <empty name="list">
                                    <li class="trends-item" style="padding-bottom:0px;">
                                        <div class="">
                                            <ul>
                                                <li class="trends-text-item clearfix">
                                                    <div class="trends-text">
                                                        项目发起人暂时没有发布项目的最新进展,请耐心等待...
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </li>
                                <else />
                                    <li class="trends-item">
                                        <div class="line-time">
                                            <div class="square"></div>
                                            <span>{$deal_info.create_time|date="Y-m",###}</span>
                                        </div>
                                    </li>
                                </empty>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <include file="right_content" />
    </div>
</div>
</div>
<script id="tpl" type="text/template">
    {@each data as vo,index}
    <li>
        <img src="${vo.avatar_small}" class="dis-list-photo">
        <span class="dis-name">${vo.user_name}：</span><span class="dis-text">${vo.content}</span>
    </li>
    {@/each}
    </script>
        <script>
            $(function(){
                function getComment(deal_id,id){
                    $.get('/deal/status_comment_ajax/?deal_id='+deal_id+'&id='+id,function(data){
                        var tpl = document.getElementById('tpl').innerHTML;
                        tpl = juicer(tpl,data);
                        $(".dis-list"+id).html( tpl );
                    },'json')
                }
                $(".appraise").on("click",function(){
                    var id = $(this).attr('data-id');
                    var deal_id = $(this).attr('deal-id');
                    getComment(deal_id,id);
                });
                $(".send-discuss").on('click',function(){
                    var id = $(this).attr('data-id');
                    var deal_id = $(this).attr('deal-id');
//                    var content = $('.content'+id).val();
                    editor.sync();
                    var content = encodeURI($('#pro_status-textarea').val());
                    if(content.length<=0){alert("请输入评论内容");return false;}
                    $.post('/deal/status_comment',{id:id,deal_id:deal_id,content:content},function(data){
                        if(data.status == 1){
//                            $('.content'+id).val('');
                            editor.html('');
                            getComment(deal_id,id);
                        }else{
                            alert(data.info);
                        }
                    },'json')
                });
                $("#send-dis").on('click',function(){
                    var _id = $(this).attr('deal-id');
                    var _content = $("#dis-content").val();
                    if(_content.length<=0){alert("请输入评论内容");return false;}
                    $.post('/Deal/post_status/',{deal_id:_id,content:_content},function(data){
                        alert(data.info);
                        if(data.status == 1){
                            window.location.reload();
                        }
                    },'json')
                })
            })
        </script>
<include file="common/footer" />